﻿using System;
using System.Windows.Forms;
using System.Diagnostics;

namespace WindowsFormsApplication11
{
    
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private Process[] currentProcess;

        private void button1_Click(object sender, EventArgs e)
        {
            listBox1.Items.Clear();
            currentProcess = Process.GetProcesses();
            foreach (var processe in currentProcess)
            {
                try
                {
                    listBox1.Items.Add(processe.ProcessName+"   ------   "+processe.Id+"  ---  " +processe.MainModule.FileName );
                }
                catch (Exception)
                {
                    ;
                }
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            
            for(int i=0;i<listBox1.SelectedIndices.Count;i++)
            {
                currentProcess[listBox1.SelectedIndices[i]].Kill();
            }

            button1_Click(sender,e);
        }


    }
}
